package online.heycm.excel.repository;

import online.heycm.excel.common.MyBatisBatch;
import online.heycm.excel.repository.entity.UserProfile;
import online.heycm.excel.repository.mapper.UserProfileMapper;
import org.apache.ibatis.session.ResultHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.util.StopWatch;

import java.util.List;

/**
 * @author hey
 * @version 1.0
 * @since 2024/8/17 20:39
 */
@Repository
public class UserRepository {

    @Autowired
    private UserProfileMapper mapper;

    public void insert(List<UserProfile> list) {
        MyBatisBatch.execute(list, UserProfileMapper.class, (userProfile, mapper) -> mapper.insertSelective(userProfile));
    }

    public void select(int maxId, ResultHandler<UserProfile> resultHandler) {
        mapper.selectStream(maxId, resultHandler);
    }

}
